package com.example.dllo.moondog.main;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.example.dllo.moondog.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/3/2.
 */
public class MyViewPagerAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> data;
    private Context context;
    private int[] imageViewArray = {R.drawable.selector_information,R.drawable.selector_chat,R.drawable.selector_video,R.drawable.selector_community};

    public MyViewPagerAdapter(FragmentManager fm,ArrayList<Fragment> data,Context context) {
        super(fm);
        this.data = data;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    public View getTabView(int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.imageview_tablayout,null);
        ImageView imgTablayout = (ImageView) view.findViewById(R.id.img_tablayout);
        imgTablayout.setImageResource(imageViewArray[position]);
        return view;
    }
}
